import request from "@/utils/request";
import type { AttrListParams, AttrList, AttrItem } from "./model/attrListModel";

enum Api {
  getAttrListUrl = "/admin/product/attrInfoList",
  saveOrUpdateAttrUrl = "/admin/product/saveAttrInfo",
  deleteAttrUrl = "/admin/product/deleteAttr",
}
export const getAttrListApi = ({
  category1Id,
  category2Id,
  category3Id,
}: AttrListParams) => {
  return request.get<any, AttrList>(
    Api.getAttrListUrl + `/${category1Id}/${category2Id}/${category3Id}`
  );
};
export const saveOrUpdateAttrApi = (body: AttrItem) => {
  return request.post<any, null>(Api.saveOrUpdateAttrUrl, body);
};

/**
 * 删除属性
 * @param id 属性ID
 * @returns null
 */
export const deleteAttrApi = (id: number) => {
  return request.delete<any,null>(Api.deleteAttrUrl + `/${id}`);
};
